//
//  SeachHeadView.m
//  InsuranceMarketing
//
//  Created by bihu_mac on 2018/2/1.
//  Copyright © 2018年 initial. All rights reserved.
//

#import "NSObject+Ivars.h"
#import "SeachHeadView.h"

@implementation SeachHeadView


-(void)setConstraints{
    [self addSubview:self.searchbar];
    [self addSubview:self.searchButton];
    WeakSelf(self);
    [self.searchButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(weakSelf).offset(-12);
        make.top.mas_equalTo(weakSelf).offset(0);
        make.bottom.mas_equalTo(weakSelf).offset(0);
        make.width.mas_offset(40);
    }];
    [self.searchbar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(weakSelf).offset(16);
        make.right.mas_equalTo(weakSelf).offset(-55);
        make.centerY.mas_equalTo(weakSelf).offset(0);
        make.height.mas_equalTo(28);
    }];
}
- (UIButton *)searchButton{
    if (!_searchButton) {
        _searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _searchButton.layer.masksToBounds = YES;
        _searchButton.layer.cornerRadius = 4;
        _searchButton.titleLabel.font =  Font(14);
        [_searchButton setTitle:@"取消" forState:(UIControlStateNormal)];
//        [_searchButton setBackgroundColor:VMRGBColor(63,158,255)];
        [_searchButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];

    }
    return _searchButton;
}
- (UISearchBar *)searchbar{
    if (!_searchbar) {
        _searchbar = [[UISearchBar alloc] init];
        _searchbar.searchBarStyle = UISearchBarStyleProminent;
        _searchbar.placeholder = @"请输入关键字搜索";
//        [_searchbar getAllIvars];
        UITextField * searchField = [_searchbar valueForKey:@"_searchField"];
        searchField.font = Font(14);
        [searchField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
//        [searchField setValue:VMFont(14) forKeyPath:@"_placeholderLabel.font"];
        _searchbar.searchBarStyle = UISearchBarStyleMinimal;

    }
    return _searchbar;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
